package cn.itcast.controller;

import cn.itcast.domain.Appointment;
import cn.itcast.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/appointment")
public class AppointmentController {


    @Resource
    private UserService service;

    @RequestMapping("/apCooker.do")
    @ResponseBody
    public Map<String, Object> apCooker(Integer orderid,Integer customerid,Integer cookid) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = df.format(new Date());
        String result=null;
        Map<String,Object> maplist=new HashMap<>();
        Boolean flag=service.addAp(orderid,customerid,cookid,date);
        if(flag){
            result="1";
        }else {
            result="0";
        }
        maplist.put("result",result);
        return maplist;
    }


    @RequestMapping("/findAppoint.do")
    @ResponseBody
    public List<Appointment> findAppoint(){
        List<Appointment> list=service.findappoint();
        return list;
    }
}
